package com.leyou.trade.config;

import com.leyou.auth.utils.TokenContext;
import feign.Request;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

/**
 * @author BaiZY on 2020/9/8.
 * @version 1.0
 */
@Component
public class FeignInterceptor implements RequestInterceptor {
    //通过feign的拦截器，向请求头中加入Cookie信息
    @Override
    public void apply(RequestTemplate template) {
        //Request request = template.request();
        template.header("Cookie", "LY_TOKEN=" + TokenContext.getToken());
    }
}
